<template>
  <div>
    <view class="Line p-2 rounded-md m-2 gap-2 flex-col flex">
      <div class="flex  items-center gap-2">
        <div :class="cur == 3 ? 'text-lg font-bold' : ''" @click="cur = 3">
          好评
        </div>
        <div :class="cur == 2 ? 'text-lg font-bold' : ''" @click="cur = 2">
          中评
        </div>
        <div :class="cur == 1 ? 'text-lg font-bold' : ''" @click="cur = 1">
          差评
        </div>
      </div>

    </view>
    <workerinformation_card class="p-4" v-for="comment in filterComments" v-bind="comment" />
  </div>
</template>

<script setup>
import { ref, computed } from 'vue'
import workerinformation_card from './workerinformation_card.vue'

const props = defineProps(['user'])
const comments = ref([])
const cur = ref(3)
const filterComments = computed(() => {
  return comments.value.filter(c => c.rate === cur.value)
})
uni.request({
  url: '/comment/user/' + props.user,
  success: ({ data }) => {
    console.log(data)
    comments.value = data
  }
})
</script>